package com.borrowed.book.config.shiro;

import com.alibaba.fastjson.JSONObject;
import com.borrowed.book.system.domain.AjaxResult;
import org.apache.shiro.web.filter.authc.UserFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;

public class ShiroUserFilter extends UserFilter {
    @Override
    protected void redirectToLogin(ServletRequest request, ServletResponse response) throws IOException {
        response.setContentType("application/json; charset=utf-8");//返回json
        response.getWriter().write(JSONObject.toJSON(AjaxResult.nologin()).toString());
    }
}
